package objbo.xmlparser.controls.action;

import java.net.URI;

import objbo.xmlparser.view.interfaces.FileInterFace;
import objbo.xmlparser.view.interfaces.UIInterFace;
import objbo.xmlparser.view.ui.FileControlUI;

import org.eclipse.jface.action.Action;

public class FileOpenAction extends Action
{
	private UIInterFace uIInterFace = null;
	private FileInterFace fileInterFace = null;
	private FileControlUI ui = null;
	private URI fileURI = null;
	

	public FileOpenAction(FileInterFace fileInterFace, UIInterFace uIInterFace)
	{
		this.fileInterFace = fileInterFace;
		this.uIInterFace = uIInterFace;
	}

	public void setFileControlUI(FileControlUI ui)
	{
		this.ui = ui;
	}
	
	
	
	public void setFileURI(URI fileURI)
	{
		this.fileURI = fileURI;
	}

	@Override
	public void run()
	{
		if(this.ui != null)
		{
			this.uIInterFace.cleatTabText();

			if( !ui.getFilePath().equals("") && ui.getFilePath() != null)
			{
				this.fileInterFace.fileLoad(ui.getFilePath());
				this.uIInterFace.setTreeUIInput();
			}
		}
		else if(this.fileURI != null)
		{
			this.fileInterFace.fileLoad(this.fileURI);
		}
	}
}
